package com.sailing.xjpb.common.tree;

import com.sailing.xjpb.common.tree.annotation.Tree;
import com.sailing.xjpb.common.tree.annotation.TreeField;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * 记录将数据对象标注的id、pid、label等字段信息
 * <p>
 * also see {@linkplain Tree}
 *
 * @author YW
 * create 2020/4/28
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TreeFieldInfo {

	/**
	 * id字段
	 */
	private Field treeIdField;
	/**
	 * 父ID字段
	 */
	private Field parentIdField;
	/**
	 * 描述信息
	 */
	private Field treeNameField;
	/**
	 * 描述信息
	 */
	private Field treeCodeField;
	/**
	 * 其他属性信息
	 */
	private Map<Field, TreeField> propertiesFields = new HashMap<>();

	/**
	 * 新增一个属性field
	 *
	 * @param propertiesField 对象的字段信息
	 */
	public void addPropertiesField(Field propertiesField, TreeField treeField) {
		propertiesFields.put(propertiesField, treeField);
	}

}
